package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "function_type", schema = "crm")
public class FunctionType {
    private int funTypeId;
    private String funTypeName;
    private Integer typeSort;
    private String funTypeIcon;
    private List<Function> functions;

    @Id
    @Column(name = "fun_type_id", nullable = false)
    public int getFunTypeId() {
        return funTypeId;
    }

    public void setFunTypeId(int funTypeId) {
        this.funTypeId = funTypeId;
    }

    @Basic
    @Column(name = "fun_type_name", nullable = true, length = 255)
    public String getFunTypeName() {
        return funTypeName;
    }

    public void setFunTypeName(String funTypeName) {
        this.funTypeName = funTypeName;
    }

    @Basic
    @Column(name = "type_sort", nullable = true)
    public Integer getTypeSort() {
        return typeSort;
    }

    public void setTypeSort(Integer typeSort) {
        this.typeSort = typeSort;
    }

    @Basic
    @Column(name = "fun_type_icon", nullable = true, length = 255)
    public String getFunTypeIcon() {
        return funTypeIcon;
    }

    public void setFunTypeIcon(String funTypeIcon) {
        this.funTypeIcon = funTypeIcon;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FunctionType that = (FunctionType) o;
        return funTypeId == that.funTypeId &&
                Objects.equals(funTypeName, that.funTypeName) &&
                Objects.equals(typeSort, that.typeSort) &&
                Objects.equals(funTypeIcon, that.funTypeIcon);
    }

    @Override
    public int hashCode() {
        return Objects.hash(funTypeId, funTypeName, typeSort, funTypeIcon);
    }


    @OneToMany(mappedBy = "functionType")
    public List<Function> getFunctions() {
        return functions;
    }

    public void setFunctions(List<Function> functions) {
        this.functions = functions;
    }
}
